package com.threeox.commonlibrary.util;

import com.threeox.ormlibrary.util.DBBaseUtil;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 *
 * @ClassName: CommonUtils
 *
 * @Description: TODO(类库的工具类)
 *
 * @author 赵屈犇
 *
 * @date 创建时间:2016/12/19 17:03
 *
 * @version 1.0
 */
public class CommonUtils extends DBBaseUtil {

    /**
     * 讲Map中的值和Key改变位置
     *
     * @param map
     */
    public static void changeKeyVal(Map map) {
        Map tempMap = new HashMap();
        Iterator it = getIter(map);
        while (it.hasNext()) {
            Object key = it.next();
            tempMap.put(map.get(key), key);
        }
        map.putAll(tempMap);
    }

    /**
     * 得到迭代器
     *
     * @param map
     * @return
     */
    public static Iterator getIter(Map map) {
        if (map == null)
            return null;
        Set set = map.keySet();
        return set.iterator();
    }

    /**
     * 判断是否为NaN
     *
     * @param val
     * @return
     */
    public static boolean isNaN(float val) {
        Float f = new Float(val);
        return f.isNaN();
    }

}
